Skip to content

fix: add pregenerate cleanup to SDK packages to remove stale files#838

Merged
pyramation merged 1 commit intomainfrom
devin/1773732461-fix-stale-codegen
Mar 17, 2026
Merged

fix: add pregenerate cleanup to SDK packages to remove stale files#838
pyramation merged 1 commit intomainfrom
devin/1773732461-fix-stale-codegen

Conversation

@pyramation
Copy link
Contributor

Summary

Adds pregenerate scripts to each SDK package that clean generated output directories before codegen runs. This prevents stale files from deleted database entities (e.g. uuidModule.ts) from persisting and causing build failures when they reference types that no longer exist.

Companion to constructive-db#595 which applies the same fix to the constructive-db repo.

Changes:

  • Added rimraf (^6.1.3) as a root devDependency
  • Added pregenerate script to constructive-sdk, constructive-cli, and constructive-react that removes src/{admin,auth,objects,public} and src/index.ts
  • Added pregenerate:migrate-client to constructive-sdk that removes ../migrate-client/src/migrate and ../migrate-client/src/index.ts
  • Updated all generate scripts to run their pregenerate step first

Review & Testing Checklist for Human

  • Verify constructive-cli cleanup list is safe: The CLI has non-generated files in src/ (cli-commands.ts, cli.ts, commands/, config/, utils/) — confirm the pregenerate list only targets generated dirs (admin, auth, objects, public, index.ts) and doesn't touch these
  • Verify pregenerate:migrate-client relative path: Runs from sdk/constructive-sdk/ and targets ../migrate-client/src/migrate — confirm this resolves correctly
  • Check pnpm-lock.yaml for unintended changes: The lockfile has @types/node version shifts (25.5.022.19.15) that appear to be pnpm re-resolution noise from adding rimraf — verify these don't cause type issues
  • End-to-end test: Run the full generation pipeline after merging and confirm stale files are properly cleaned and builds pass

Notes

  • The cleanup lists are hardcoded — if new codegen targets are added in the future, the pregenerate scripts will need updating to include them.
  • This does not modify the codegen library itself (@constructive-io/graphql-codegen); the cleanup is at the script level.

Link to Devin session: https://app.devin.ai/sessions/08781f0838fd4c929bb5ab08052b2b5a
Requested by: @pyramation

Each generate script now cleans its output directory via rimraf before
running codegen. This prevents stale files from deleted database
entities from persisting and causing build failures.

Affected packages:
- constructive-sdk: cleans src/{admin,auth,objects,public}
- constructive-cli: cleans src/{admin,auth,objects,public}
- constructive-react: cleans src/{admin,auth,objects,public}
- migrate-client (via constructive-sdk): cleans src/migrate
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit f4c3938 into main Mar 17, 2026
43 checks passed
@pyramation pyramation deleted the devin/1773732461-fix-stale-codegen branch March 17, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant